home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 May: Tool Chest / Developer CD Series Tool Chest (Apple Computer)(May 1999).iso / Tool Chest / Development Kits / MPW Related / DTS MPW Goodies / CheckWindowIn < prev    next >
Encoding:
Text File  |  1990-09-14  |  4.4 KB  |  183 lines  |  [TEXT/MPS ]

  1. #
  2. #    File:        CheckWindowIn
  3. #
  4. #    Contains:    script to check a window in
  5. #
  6. #    Usage:        CheckWindowIn window
  7. #
  8. #    Status:        CheckWindowIn may return the following status values:
  9. #
  10. #                    0        the window was checked in
  11. #                    1        error
  12. #                    2        the user canceled
  13. #
  14. #                CheckWindowIn presents a dialog that allows the user to type
  15. #                in a short comment that indicates what changes have been made
  16. #                to the file since it was checked out. These will be logged into
  17. #                the project, and into the file.
  18. #
  19. #    Written by:    Darin Adler and scott douglass
  20. #
  21. #    Copyright:    © 1988, 1989 by Apple Computer, Inc., all rights reserved.
  22. #
  23. #    Change History (maintain by hand, CheckWindowIn confuses itself by editing itself):
  24. #
  25. #                  1/3/90    dba        pass suffix to FindChange
  26. #                12/29/89    dba        don’t bother stripping the file (too slow)
  27. #                11/15/89    dba        change comment handling a bit
  28. #                 11/9/89    dba        stopped using LastChange marker; invented mark character
  29. #
  30. #    To Do:
  31. #        a way to keep working (keep the modifiable)
  32. #        a way to introduce a new branch
  33. #        a way to enter a “task”
  34. #        make ModifyReadOnly work even better by getting NewVersion from project
  35. #
  36.  
  37. Set Exit 0
  38.  
  39. # the following helps to debug until MPW sends echos to Dev:Console instead of Dev:StdErr
  40.  
  41. If {Echo}
  42.     Set somewhere "∑∑ '{Worksheet}'"
  43. Else
  44.     Set somewhere "∑ Dev:Null"
  45. End
  46.  
  47. Begin
  48.  
  49.     Set OldComment "{SystemFolder}OldComment"
  50.     Set NewComment "{SystemFolder}NewComment"
  51.     Set CheckInErrors "{SystemFolder}CheckInErrors"
  52.     Set Window "{1}"
  53.  
  54.     # get short name of window
  55.  
  56.     If "{Window}" !~ /:*([¬:]+:*)*([¬:]+)®1/
  57.         Alert "Can’t parse window parameter."
  58.         Exit 1
  59.     End
  60.     Set Short "{®1}"                    # get short name for dialogs
  61.     Set Cant "“{Short}” can’t be checked in"
  62.  
  63.     # check what project the window belongs to
  64.  
  65.     Set Info "`ProjectInfo "{Window}" -comments`"
  66.  
  67.     Unset New
  68.     Unset OldVersion
  69.     Unset NewVersion
  70.     Unset Project
  71.  
  72.     Set GotOldComment 0
  73.  
  74.     If "{Info}" !~ /[¬,]+,([0-9]+)®1([∂+∂*]«0,1»)®3≈Project: ([¬:]+∫)®2     Checked out: ≈/
  75.         If `Project` == ""
  76.             Alert "{Cant} because there are no projects mounted."
  77.             Exit 1
  78.         End
  79.  
  80.         Set New "-new -project `GetListItem -r 10 ∂`MountProject -pp -s -r∂` -d ∂`Project∂` ∂
  81.             -m "“{Short}” isn’t in a project. Choose one to add it to:"; Set GetListItemStatus {Status}`"
  82.         Exit 2 If {GetListItemStatus}
  83.  
  84.         Echo -n "first checked in" > "{OldComment}"
  85.         Set GotOldComment 1
  86.  
  87.         If "{InitialVersion}" ≠ ""
  88.             Set NewVersion "{InitialVersion}"
  89.         Else
  90.             Set NewVersion 1
  91.         End
  92.     Else
  93.         Set OldVersion {®1}
  94.         Set NewVersion `Evaluate {OldVersion} + 1`
  95.         Set OldVersion "{OldVersion}{®3}"
  96.         Set Project "{®2}"
  97.  
  98.  
  99.         # check if the project is mounted
  100.  
  101.         ProjectInfo -project "{Project}" -only
  102.         If {Status}
  103.             Alert "{Cant} because the project “{Project}” is not mounted."
  104.             Exit 1
  105.         End
  106.  
  107.         # ensure that the window is checked out
  108.  
  109.         If "{Info}" !~ /[¬,]+,[¬ ∂t]+[∂+∂*]≈/
  110.             Alert "{Cant} because it wasn’t checked out."
  111.             Exit 1
  112.         End
  113.  
  114.         # parse an old comment if it is present
  115.  
  116.         If "{Info}" =~ /≈Comment: +(≈)®1/
  117.             Echo -n "{®1}" > "{OldComment}"
  118.             Set GotOldComment 1
  119.         End
  120.     End
  121.  
  122.     If {ProjectHeaders}
  123.         Mark -y § OldSelection "{Window}"
  124.         If "{OldVersion}" ≠ ""
  125.             FindChange "{Window}" "{OldVersion}" "{OldComment}" && Set GotOldComment 1
  126.         End
  127.     End
  128.  
  129.     Set GetOldComment ""
  130.     If {GotOldComment}
  131.         Set GetOldComment "-d < ∂"{OldComment}∂""
  132.     End
  133.  
  134.     Set IgnoreCmdPeriod 1
  135.         CoolRequest -q {GetOldComment} "What did you change in “{Short}”?" > "{NewComment}"
  136.         Set CommentStatus {Status}
  137.     Set IgnoreCmdPeriod 0
  138.  
  139.     Delete -i "{OldComment}"
  140.  
  141.     If {CommentStatus}
  142.         If {ProjectHeaders}
  143.             Find OldSelection "{Window}"
  144.             Unmark OldSelection "{Window}"
  145.         End
  146.         Delete -i "{NewComment}"
  147.         Exit 2
  148.     End
  149.  
  150.     If {ProjectHeaders}
  151.  
  152.         # add/modify a change in the change history
  153.  
  154.         Evaluate "`Files -n -q -x m "{Window}"`" =~ /[¬∂/]+ ([1-9]≈)®1/
  155.         Set Date "{®1}"                    # get date before adding change
  156.  
  157.         Clear § "{Window}"                # get rid of the old change
  158.         AddChange "{Window}" "{NewVersion}" "{NewComment}"
  159.         If {Status}                        # if we canceled
  160.             Find OldSelection "{Window}"
  161.             Unmark OldSelection "{Window}"
  162.             Exit 2
  163.         End
  164.  
  165.         SetFile -m "{Date}" "{Window}"    # set date back to before change
  166.  
  167.         Find OldSelection "{Window}"
  168.         Unmark OldSelection "{Window}"
  169.         Save "{Window}"                    # save before checking in
  170.  
  171.     End
  172.  
  173.     CheckIn {New} -cf "{NewComment}" "{Window},{NewVersion}" ∑ "{CheckInErrors}"
  174.     Set CheckInStatus {Status}
  175.     Delete -i "{NewComment}"
  176.     If {CheckInStatus}
  177.         Alert "{Cant}. You may need to check it in on a branch.∂n`Catenate "{CheckInErrors}"`"
  178.         Exit 1
  179.     End
  180.     Delete -i "{CheckInErrors}"
  181.  
  182. End {somewhere}
  183.